<%@ page language="java" contentType="text/html; charset=windows-1255" pageEncoding="windows-1255"%>
<%@ include file="admin_Header.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script>
<%
	double latitude = Double.parseDouble(request.getParameter("latitude"));
	double longitude = Double.parseDouble(request.getParameter("longitude"));
%>
<title>List Products</title>
</head>
<body>
<div data-role="page">
	<div data-role="header" align="center">
		<h1>Products Compare<br>Application</h1>
		<a href='#' class='ui-btn-left' data-icon='arrow-l' onclick="history.back(); return false">Back</a><a href="#user_firstpage">Home</a>
	</div>
	
	<div data-role="content" align="center">
<%
	try
	{
		List<Product> products = iproducts.FindAllProducts();
		for (Product product : products)
		{
			out.println("<table border=1><tr bgcolor=\"grey\"><tr colspan=4>" + product.getProductName() + "</th></tr>");
			out.println("<tr bgcolor=\"grey\"><th>Product Unit</th><td>" + product.getProductUnit() + "</td>");
			out.println("<th>Unit Quantity</th><td>" + product.getProductQuantityPerUnit().toString() + "</td></tr>");
			Set<ProductSupermarket> productSupermarkets = iproducts.FindAllProductSupermarkets(product);
			out.println("<tr bgcolor=\"grey\"><th>SuperMarket</th><th>Price</th><th>Unit</th><th>Quantity Per Unit</th></tr>");
			for (Iterator<ProductSupermarket> iterPS = productSupermarkets.iterator(); iterPS.hasNext();)
			{
				ProductSupermarket productSupermarket = (ProductSupermarket) iterPS.next();
				out.println("<tr><td>" + productSupermarket.getSupermarket().getSupermarketName() + "</td>");
				out.println("<td>" + productSupermarket.getPrice() + "</td>");
				out.println("</tr>");
			}
			out.println("</table><br>");
		}
	}
	catch (Exception e)
	{
	    throw new Exception("Error in connecting to database, please contact your administrator");
	}
%>
	</div>
</div>
</body>
</html>